package com.zxy.service;

import com.zxy.dao.Order;
import com.zxy.dao.OrderMapper;
import com.zxy.dao.OrderStatusConstant;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.mockito.internal.matchers.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author : zhangxuyuan
 * @Project: rocketmqtest
 * @Package com.zxy.service
 * @date Date : 2021年05月25日 21:22
 *
 * 订单监听
 */
@Service
@RocketMQMessageListener(topic = "flashsale",consumerGroup = "orderlistener")
public class OrderListener implements RocketMQListener<String> {

    @Autowired
    OrderMapper orderMapper;

    @Override
    public void onMessage(String s) {
        //将订单插入数据表，状态为未支付
        Order order=new Order(s, OrderStatusConstant.ORDER_NOT_PAY);
        orderMapper.insert(order);
    }
}
